#include "mm.h"
#include <stdlib.h>

int main(){
    char *ptr1, *ptr2, *ptr3;
    int i;
    
    // initialize the memory library
    mm_init(4000); // memory pool size = 4000 bytes
    
    ptr1=mm_alloc(10);
    //Start barrier 0
    
    for (i=0; i<11;i++) {
        // Should return buffer overflow error on 11th iteration
        mm_assign(ptr1+i,(char)i);
        // It is similar to ptr1[i] = (char)i
    }
    
    
    ptr2=mm_alloc(1);
    mm_assign(ptr2+1, (char)2); //Buffer overflow error
    mm_free(ptr2);
    
    
    mm_free (ptr2); // Double free
    ptr3=mm_alloc(1);
    mm_assign(ptr3, (char)3);
    
    
    
    mm_end();
}
